package top.suven.base.core.httpclient;

import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

public class Response {
	private int code ;
	
	private String body ; 
	
	private Map<String,String> headerMap ;

	

	public boolean isSuccess() {
		return code == HttpStatus.SC_OK ;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}
	
	public void putHeader(String name , String value){
		if(headerMap == null){
			headerMap = new HashMap<String, String>() ;
		}
		headerMap.put(name, value) ;
	}
	
	public Map<String, String> getHeaderMap() {
		return headerMap;
	}
	
	public String getHeader(String name) {
		return headerMap == null ? null : headerMap.get(name);
	}

	@Override
	public String toString() {
		return "Response [code=" + code + ", body=" + body + "]";
	}
}
